package cn.hbads.support.id;


import cn.hbads.support.context.SpringContextHolder;
import cn.hbads.support.id.support.SnowIdGenerator;

import java.util.UUID;

/**
 * <b> ID生成工具类 </b>
 *
 * @author : yvvb
 * @date : 2025/4/20
 */
public final class IdUtil {
    private IdUtil() {
    }

    private static class IdGeneratorHolder {
        private static final SnowIdGenerator DEFAULT_SNOW_ID_GENERATOR = new SnowIdGenerator(0, 0);
        public static SnowIdGenerator idGenerator = SpringContextHolder.getBean(SnowIdGenerator.class).orElse(DEFAULT_SNOW_ID_GENERATOR);
    }

    public static Long snowId() {
        return IdGeneratorHolder.idGenerator.nextId();
    }

    public static UUID uuid() {
        return UUID.randomUUID();
    }

    public static String uuidStr() {
        return UUID.randomUUID().toString();
    }
}